/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.uct.service.plugins  
 */
package com.apache.audit.service.plugins;

import org.apache.log4j.Logger;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.auditRule.entity.Audit;
import com.apache.auditRule.manager.AuditManager;
import com.apache.cache.util.Validator;
import com.apache.tools.ClassToolsUtil;

public class AuditInfoPluginImpl implements PluginConnector {

	private Logger log = Logger.getLogger(AuditInfoPluginImpl.class);

	private AuditManager auditManager;

	public Object execute(ParamsVo vo) throws Exception {
		ResultEntity result = new ResultEntity();
		try {
			result.setResult("true");

			Audit audit = new Audit();
			audit = (Audit) ClassToolsUtil.getInstance().convert2Bean(vo.getParams(), audit);//主要是auditId，相当于工作流的taskId
			ParamsVo<Audit> auditVo = new ParamsVo<Audit>();
			auditVo.setInfoId(Validator.getDefaultStr(audit.getAuditsId(), ""));
			return auditManager.getInfoById(auditVo);

		} catch (Exception e) {
			result.setResult("false");
			log.error("执行查询失败 ", e);
			result.setMessage("查询失败！");
		}
		return result;
	}

	public void setAuditManager(AuditManager auditManager) {
		this.auditManager = auditManager;
	}

}
